home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripts / js / myclasses / toolbars / mydeform.js < prev    next >
Encoding:
Text File  |  2005-04-04  |  1.6 KB  |  70 lines

  1.  
  2. //
  3. // Description:
  4. //     Deformation tools. Uses ENUMSELECTLIST() layer method to enumerate 
  5. //      selected objects to a user specific callback function. Uses GETPOINT() and SETPOINT()
  6. //      methods to deform the geometry. 
  7. //
  8. // Super class:
  9. //      myclasses/toolbars/toolbar.js
  10. //
  11. // Constructor:
  12. //      toolbar = new myDeformationTools();
  13. //
  14. // Attributes:
  15. //      --
  16. //
  17. // Methods:
  18. //      --
  19. //
  20.  
  21. include("myclasses/toolbars/mytoolbar.js"); // super class
  22. include("real/objects/r3prim.js");
  23. include("real/layer/r3prilay.js");
  24.  
  25. // geometric objects
  26.  
  27. function myNoiseCallback(r3obj, data)
  28. {
  29.     obj = R3ToJS(r3obj);
  30.     if(!obj)
  31.         return 0;
  32.     p = new r3Vect();
  33.     pcount = obj.GetPointCount();
  34.  
  35.     for(i = 0; i < pcount; i++) {
  36.         obj.GETPOINT(p, i);
  37.         p2 = p.noise(3, 3);
  38.         p2.fmul(0.1);
  39.         obj.SETPOINT(i, p2);
  40.     }
  41.     return 1;
  42. }
  43.     
  44. function mydfrmNoise(button, event, value)
  45. {
  46.     button.layer.LOCKEXCLUSIVE(0);
  47.     button.layer.ENUMSELECTLIST([R3RA_Hook, myNoiseCallback,
  48.                                  R3PLAYA_Recursive, TRUE]);
  49.     button.layer.RELEASE(0);
  50.     button.layer.CHANGED([R3PRIMM_SETPOINT, 0]);
  51. }
  52.  
  53. function myDeformationTools(orientation)
  54. {
  55.     if(arguments.length == 0)
  56.         return;
  57.  
  58.     // create JavaScript interface for accessing geometric objects layer
  59.     primLayer = GetJS("CurrentProject.Geometrics");
  60.  
  61.     // let the super class to do its job
  62.     this.base = myToolBar; 
  63.     this.base("Deformation Tools", VERTICAL, primLayer);
  64.  
  65.     // Add tool buttons.
  66.     this.AddTool("Noise",  mydfrmNoise);
  67. }
  68.  
  69. myDeformationTools.prototype=new myToolBar;
  70.